<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.10/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- 
        .prevent修饰符:
          阻止当前事件的默认行为
        .once修饰符:
          当前事件只能触发一次
        -->
        <!-- 
        .capture修饰符:
          控制当前事件在捕获阶段触发(如果不写,默认都是在冒泡阶段触发)
        .stop修饰符:
          阻止当前事件的传播
          如果要阻止捕获,在最外层元素上书写
          如果要阻止冒泡,在最内层元素上书写
       -->
        <!-- 
        .self修饰符:
          控制只有在当前绑定事件的元素上发生事件,才能触发事件
       -->
        <button @contextmenu.prevent="contextMenu">阻止右键</button>
        <div @click.capture.stop="outerClick">
            outer
            <div @click="innerClick">
                inner
                <div @click.stop="contentClick">
                    content
                </div>
            </div>
        </div>
    </div>
    <script>
        const vm = new Vue({
            el: "#app",
            data() {
                return {};
            },
            methods: {
                contextMenu() {
                    console.log("右键触发");
                },
                outerClick() {
                    console.log("outer");
                },
                innerClick() {
                    console.log("inner");
                },
                contentClick() {
                    console.log("content");
                },
            },
        });
    </script>
</body>
</html>